package demo;

public class LinkedListOperations {
    public static void 定义一条empty的链表(){
        Node head=null;
    }

    public static Node 定义一条4个元素的链表(){
       //
        Node n1=new Node(1);
        Node n2=new Node(2);
        Node n3=new Node(3);
        Node n4=new Node(4);

        n1.next=n2;
        n2.next=n3;
        n3.next=n4;
        n4.next=null;

        Node head=n1;

        return head;
    }
    public static void 遍历并打印每个元素(Node head){
        for(Node cur=head;cur!=null;cur=cur.next){
            System.out.println(cur.val);
        }
    }

    public static void main(String[] args) {
        Node head=定义一条4个元素的链表();
        遍历并打印每个元素(head);

    }
}
